# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Maintainer: Fabian Affolter <fabian@affolter-engineering.ch>
pkgname=py3-pytest
pkgver=7.4.4
pkgrel=0
pkgdesc="Python3 testing library"
url="https://docs.pytest.org/en/latest/"
arch="noarch"
license="MIT"
depends="
	py3-iniconfig
	py3-packaging
	py3-pluggy
	py3-py
	python3
	"
makedepends="py3-gpep517 py3-setuptools py3-wheel"
checkdepends="bash py3-hypothesis py3-virtualenv py3-xmlschema"
subpackages="$pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/p/pytest/pytest-$pkgver.tar.gz
	"
builddir="$srcdir/pytest-$pkgver"
options="!check" # causes bootstrapping issues because of checkdepends

replaces="pytest" # Backwards compatibility
provides="pytest=$pkgver-r$pkgrel" # Backwards compatibility

prepare() {
	default_prepare

	sed -e "/^\[metadata\]/a version = $pkgver" -i setup.cfg
}

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages test-env
	test-env/bin/python3 -m installer .dist/pytest*.whl

	test-env/bin/python3 -m pytest
}

package() {
	mkdir -p "$pkgdir"/usr/bin

	local name; for name in py.test pytest; do
		ln -s $name-3 "$pkgdir"/usr/bin/$name
	done

	python3 -m installer -d "$pkgdir" \
		.dist/pytest*.whl
}

sha512sums="
28a259dac6739683c131993409d508e10fbfee461291b8fc7697dd83f30725a3c60e681ba00b5669a215af6a5e683f07a329485d780acc9ad0372a6552f783a1  pytest-7.4.4.tar.gz
"
